package com.fc.advbox.controller.admin;

import com.fc.advbox.entity.SysConfigEntity;
import com.fc.advbox.service.ISysConfigService;
import com.fc.advbox.utils.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/admin/sys/config")
@Api(value="系统配置相关的API", tags={"系统配置接口"})
public class SysConfigController extends BaseController{
    private ISysConfigService sysConfigService;

    @Autowired
    public SysConfigController(ISysConfigService sysConfigService){
        this.sysConfigService = sysConfigService;
    }

    @RequestMapping("/id/{id}")
    public R getSysConfigureById(@PathVariable("id") Long id){
        SysConfigEntity sysConfig = sysConfigService.queryObject(id);
        return R.ok().put("sysConfig", sysConfig);
    }

    @RequestMapping("/key/{key}")
    public R getSysConfigureByKey(@PathVariable("key") String key){
        String value = sysConfigService.getValue(key, "");
        return R.ok().put("configValue", value);
    }
}
